import request from "@/utils/request"
// pc端固定客户端授权id
const clientId = import.meta.env.VITE_APP_CLIENT_ID
// 登录方法
export function login(mobile, code) {
  const data = {
    mobile,
    code,
  }
  const params = {
    ...data,
    tenantId: data.tenantId || '000000',
    clientId: data.clientId || clientId,
    grantType: data.grantType || 'sms'
  }
  return request({
    url: '/api/fx/wx/auth/login',
    headers: {
      isToken: false
    },
    method: 'post',
    data: params
  })
}

export function getUserInfo() {
  return request({
    url: '/api/fx/wx/auth/info',
    headers: {
      isToken: true
    },
    method: 'get',
  })
}

// 退出方法
export function logout() {
  return request({
    url: '/api/fx/wx/auth/logout',
    // headers: {
    //   isToken: false
    // },
    method: 'post'
  })
}

export function sendCode(mobile) {
  return request({
    url: '/api/fx/wx/client/sendCode',
    method: 'post',
    data: {
      phone: mobile
    },
  })
}

export function sendBindSmsCode(mobile) {
  return request({
    url: '/api/fx/wx/client/send-bind-sms-code',
    method: 'get',
    params: {
      phone: mobile
    },
  })
}
